<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisProjectUserListTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisProjectUserListTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisProjectUserListTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisProjectUserListTable $MantisProjectUserListTable the actual MantisProjectUserListTable data class being edited
	 * @property QIntegerTextBox $ProjectIdControl
	 * @property-read QLabel $ProjectIdLabel
	 * @property QIntegerTextBox $UserIdControl
	 * @property-read QLabel $UserIdLabel
	 * @property QIntegerTextBox $AccessLevelControl
	 * @property-read QLabel $AccessLevelLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisProjectUserListTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisProjectUserListTable objMantisProjectUserListTable
		 * @access protected
		 */
		protected $objMantisProjectUserListTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisProjectUserListTable's individual data fields
		/**
		 * @var QIntegerTextBox txtProjectId
		 * @access protected
		 */
		protected $txtProjectId;
		/**
		 * @var QIntegerTextBox txtUserId
		 * @access protected
		 */
		protected $txtUserId;
		/**
		 * @var QIntegerTextBox txtAccessLevel
		 * @access protected
		 */
		protected $txtAccessLevel;

		// Controls that allow the viewing of MantisProjectUserListTable's individual data fields
		/**
		 * @var QLabel lblProjectId
		 * @access protected
		 */
		protected $lblProjectId;
		/**
		 * @var QLabel lblUserId
		 * @access protected
		 */
		protected $lblUserId;
		/**
		 * @var QLabel lblAccessLevel
		 * @access protected
		 */
		protected $lblAccessLevel;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisProjectUserListTableMetaControl to edit a single MantisProjectUserListTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisProjectUserListTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisProjectUserListTableMetaControl
		 * @param MantisProjectUserListTable $objMantisProjectUserListTable new or existing MantisProjectUserListTable object
		 */
		 public function __construct($objParentObject, MantisProjectUserListTable $objMantisProjectUserListTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisProjectUserListTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisProjectUserListTable object
			$this->objMantisProjectUserListTable = $objMantisProjectUserListTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisProjectUserListTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisProjectUserListTableMetaControl
		 * @param integer $intProjectId primary key value
		 * @param integer $intUserId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisProjectUserListTable object creation - defaults to CreateOrEdit
 		 * @return MantisProjectUserListTableMetaControl
		 */
		public static function Create($objParentObject, $intProjectId = null, $intUserId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intProjectId) && strlen($intUserId)) {
				$objMantisProjectUserListTable = MantisProjectUserListTable::Load($intProjectId, $intUserId);

				// MantisProjectUserListTable was found -- return it!
				if ($objMantisProjectUserListTable)
					return new MantisProjectUserListTableMetaControl($objParentObject, $objMantisProjectUserListTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisProjectUserListTable object with PK arguments: ' . $intProjectId . ', ' . $intUserId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisProjectUserListTableMetaControl($objParentObject, new MantisProjectUserListTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisProjectUserListTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisProjectUserListTable object creation - defaults to CreateOrEdit
		 * @return MantisProjectUserListTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intProjectId = QApplication::PathInfo(0);
			$intUserId = QApplication::PathInfo(1);
			return MantisProjectUserListTableMetaControl::Create($objParentObject, $intProjectId, $intUserId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisProjectUserListTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisProjectUserListTable object creation - defaults to CreateOrEdit
		 * @return MantisProjectUserListTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intProjectId = QApplication::QueryString('intProjectId');
			$intUserId = QApplication::QueryString('intUserId');
			return MantisProjectUserListTableMetaControl::Create($objParentObject, $intProjectId, $intUserId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QIntegerTextBox txtProjectId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtProjectId_Create($strControlId = null) {
			$this->txtProjectId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtProjectId->Name = QApplication::Translate('Project Id');
			$this->txtProjectId->Text = $this->objMantisProjectUserListTable->ProjectId;
			$this->txtProjectId->Required = true;
			return $this->txtProjectId;
		}

		/**
		 * Create and setup QLabel lblProjectId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblProjectId_Create($strControlId = null, $strFormat = null) {
			$this->lblProjectId = new QLabel($this->objParentObject, $strControlId);
			$this->lblProjectId->Name = QApplication::Translate('Project Id');
			$this->lblProjectId->Text = $this->objMantisProjectUserListTable->ProjectId;
			$this->lblProjectId->Required = true;
			$this->lblProjectId->Format = $strFormat;
			return $this->lblProjectId;
		}

		/**
		 * Create and setup QIntegerTextBox txtUserId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtUserId_Create($strControlId = null) {
			$this->txtUserId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtUserId->Name = QApplication::Translate('User Id');
			$this->txtUserId->Text = $this->objMantisProjectUserListTable->UserId;
			$this->txtUserId->Required = true;
			return $this->txtUserId;
		}

		/**
		 * Create and setup QLabel lblUserId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblUserId_Create($strControlId = null, $strFormat = null) {
			$this->lblUserId = new QLabel($this->objParentObject, $strControlId);
			$this->lblUserId->Name = QApplication::Translate('User Id');
			$this->lblUserId->Text = $this->objMantisProjectUserListTable->UserId;
			$this->lblUserId->Required = true;
			$this->lblUserId->Format = $strFormat;
			return $this->lblUserId;
		}

		/**
		 * Create and setup QIntegerTextBox txtAccessLevel
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtAccessLevel_Create($strControlId = null) {
			$this->txtAccessLevel = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtAccessLevel->Name = QApplication::Translate('Access Level');
			$this->txtAccessLevel->Text = $this->objMantisProjectUserListTable->AccessLevel;
			$this->txtAccessLevel->Required = true;
			return $this->txtAccessLevel;
		}

		/**
		 * Create and setup QLabel lblAccessLevel
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblAccessLevel_Create($strControlId = null, $strFormat = null) {
			$this->lblAccessLevel = new QLabel($this->objParentObject, $strControlId);
			$this->lblAccessLevel->Name = QApplication::Translate('Access Level');
			$this->lblAccessLevel->Text = $this->objMantisProjectUserListTable->AccessLevel;
			$this->lblAccessLevel->Required = true;
			$this->lblAccessLevel->Format = $strFormat;
			return $this->lblAccessLevel;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisProjectUserListTable object.
		 * @param boolean $blnReload reload MantisProjectUserListTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisProjectUserListTable->Reload();

			if ($this->txtProjectId) $this->txtProjectId->Text = $this->objMantisProjectUserListTable->ProjectId;
			if ($this->lblProjectId) $this->lblProjectId->Text = $this->objMantisProjectUserListTable->ProjectId;

			if ($this->txtUserId) $this->txtUserId->Text = $this->objMantisProjectUserListTable->UserId;
			if ($this->lblUserId) $this->lblUserId->Text = $this->objMantisProjectUserListTable->UserId;

			if ($this->txtAccessLevel) $this->txtAccessLevel->Text = $this->objMantisProjectUserListTable->AccessLevel;
			if ($this->lblAccessLevel) $this->lblAccessLevel->Text = $this->objMantisProjectUserListTable->AccessLevel;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISPROJECTUSERLISTTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisProjectUserListTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisProjectUserListTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtProjectId) $this->objMantisProjectUserListTable->ProjectId = $this->txtProjectId->Text;
				if ($this->txtUserId) $this->objMantisProjectUserListTable->UserId = $this->txtUserId->Text;
				if ($this->txtAccessLevel) $this->objMantisProjectUserListTable->AccessLevel = $this->txtAccessLevel->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisProjectUserListTable object
				$this->objMantisProjectUserListTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisProjectUserListTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisProjectUserListTable() {
			$this->objMantisProjectUserListTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisProjectUserListTable': return $this->objMantisProjectUserListTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisProjectUserListTable fields -- will be created dynamically if not yet created
				case 'ProjectIdControl':
					if (!$this->txtProjectId) return $this->txtProjectId_Create();
					return $this->txtProjectId;
				case 'ProjectIdLabel':
					if (!$this->lblProjectId) return $this->lblProjectId_Create();
					return $this->lblProjectId;
				case 'UserIdControl':
					if (!$this->txtUserId) return $this->txtUserId_Create();
					return $this->txtUserId;
				case 'UserIdLabel':
					if (!$this->lblUserId) return $this->lblUserId_Create();
					return $this->lblUserId;
				case 'AccessLevelControl':
					if (!$this->txtAccessLevel) return $this->txtAccessLevel_Create();
					return $this->txtAccessLevel;
				case 'AccessLevelLabel':
					if (!$this->lblAccessLevel) return $this->lblAccessLevel_Create();
					return $this->lblAccessLevel;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisProjectUserListTable fields
					case 'ProjectIdControl':
						return ($this->txtProjectId = QType::Cast($mixValue, 'QControl'));
					case 'UserIdControl':
						return ($this->txtUserId = QType::Cast($mixValue, 'QControl'));
					case 'AccessLevelControl':
						return ($this->txtAccessLevel = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>